<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ page trimDirectiveWhitespaces="true"%>
<!DOCTYPE html>
<html lang=ko>
<head>
<meta charset=utf-8 />
<meta name=viewport content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no" />
<meta http-equiv=X-UA-Compatible content="IE=edge,chrome=1" />
<link rel="shortcut icon" href=assets/ico/favicon.png />
<link rel=apple-touch-icon-precomposed href=assets/ico/apple-touch-icon-57-precomposed.png />
<link rel=apple-touch-icon-precomposed sizes=72x72 href=assets/ico/apple-touch-icon-72-precomposed.png />
<link rel=apple-touch-icon-precomposed sizes=114x114 href=assets/ico/apple-touch-icon-114-precomposed.png />
<link rel=apple-touch-icon-precomposed sizes=144x144 href=assets/ico/apple-touch-icon-144-precomposed.png />
<link rel=stylesheet type=text/css href=assets/css/bootstrap.min.css />
<link rel=stylesheet type=text/css href=assets/css/nanumfont.css />
<link rel=stylesheet type=text/css href=assets/font-awesome-4.0.3/css/font-awesome.min.css />
<!--[if lt IE 9]>
<script type=text/javascript src=assets/js/html5shiv.js></script>
<script type=text/javascript src=assets/js/respond.min.js></script>
<![endif]-->
<!--[if gt IE 9]>
<link rel=stylesheet type=text/css href=assets/css/ie10.css />
<script type=text/javascript src=assets/js/ie10.js></script>
<![endif]-->
<title>최종경로</title>
<link rel=stylesheet href=assets/css/rout.css>
</head>
<body>
<div id=myModal class="modal fade" role=dialog aria-labelledby=myModalLabel aria-hidden=true data-backdrop=false>
<div class=modal-dialog>
<div class=modal-body>
<p>알람을 설정 하시겠습니까??</p>
</div>
<div class=modal-footer>
<button type=button class="btn btn-inverse nav_btns" data-dismiss=modal>NO</button>
<button type=button class="btn btn-inverse nav_btns" onclick="location.replace('index.jsp');return false">YES</button>
</div>
</div>
</div>
<nav class="navbar navbar-fixed-top" role=navigation>
<div class="nav_content text-center">
<div class=pull-left>
<div class="nav_menu_btn pull-left text-center">
<a class=back_btn onclick=history.back()><i class="fa fa-arrow-left"></i></a>
</div>
</div>
<span class=page_title><strong>이동시작</strong></span>
<div class="submit_btn pull-right text-center">
<a href="javascript:$('#sr-to-ap').submit()"><i class="fa fa-home"></i></a>
</div>
</div>
</nav>
<div class=cel-box>
<div class=cel-content>
<div id=carousel-example-generic class="carousel slide" data-ride=carousel>
<ol class=step-array>
<li class="label label-danger">step1</li>
<li class="label label-default">step2</li>
<li class="label label-default">step3</li>
</ol>
<div class=carousel-inner>
<div class="item active text-center">
<div>
<div class="inline-block marin-top-50">
아이콘
</div>
<div class=inline-block>
<div>Media heading</div>
설명
</div>
</div>
</div>
</div>
<a class="left caro-control-left text-center" href=#carousel-example-generic data-slide=prev>
<span class="glyphicon glyphicon-chevron-left text-info"></span>
</a>
<a class="right caro-control-right text-center" href=#carousel-example-generic data-slide=next>
<span class="glyphicon glyphicon-chevron-right text-info"></span>
</a>
</div>
</div>
</div>
<div class="list-box panel-group">
</div>
<script src=assets/js/jquery.js></script>
<script src=assets/js/bootstrap.min.js></script>
<script src=assets/js/cordova.js></script>
<script type=text/javascript>var dbSize=1*1024*1024;var journeyAlDB=openDatabase("JourneyAlDB","1.0","내 루트 알람DB",dbSize);var key=sessionStorage.journey_key;var legs=JSON.parse(localStorage[key]);var is_al=null;var al_info=null;var step=0;document.addEventListener("deviceready",onDeviceReady,false);var watchID=null;function onDeviceReady(){var a={timeout:30000};watchID=navigator.geolocation.watchPosition(onSuccess,onError,a)}function onSuccess(a){if(step>=is_al.length){navigator.geolocation.clearWatch(watchID);watchID=null}if(step!=0){if(is_al[step]==0){step++}else{if(is_al[step]==1){if(distance(legs.steps[step-1].end_location.nb,legs.steps[step-1].end_location.ob,a.coords.latitude,a.coords.longitude)<parseInt(al_info[step])){playBeep();vibrate();step++}}}}}function onError(a){alert("code: "+a.code+"\nmessage: "+a.message+"\n")}function playBeep(){navigator.notification.beep(2)}function vibrate(){navigator.notification.vibrate(30000)}journeyAlDB.transaction(function(a){a.executeSql("SELECT is_al, al_info FROM journeyAlDB WHERE key = ?",[key],start,function(b,c){alert(c.message);console.log(c.message)})});var time=new Date();var hh=time.getHours();var mm=time.getMinutes();var dt=legs.departure_time.text.split(" ");var dtime=dt[1].split(":");var ampm=dt[0];var dhh=dtime[0];var dmm=dtime[1];if(ampm=="오후"){if(dhh==12){dhh=12}else{dhh=Number(dhh)+12}}else{if(ampm=="오전"){if(dhh==12){dhh=0}}}function toRadians(a){return a*Math.PI/180}function distance(f,i,e,h){var g=6378.1;var j=toRadians(e-f);var b=toRadians(h-i);f=toRadians(f);e=toRadians(e);var m=Math.sin(j/2)*Math.sin(j/2)+Math.cos(f)*Math.cos(e)*Math.sin(b/2)*Math.sin(b/2);var l=2*Math.atan2(Math.sqrt(m),Math.sqrt(1-m));var k=g*l;return k*1000}function start(g,e){var d=e.rows.item(0).is_al;var b=e.rows.item(0).al_info;is_al=d.split(",");al_info=b.split(",");var j="";for(var f=0;f<legs.steps.length;f++){j+='<div class="metro-image">';if(legs.steps[f]==legs.steps[0]){j+='<div class="start">'+legs.start_address+"</div>"}else{if(legs.steps[f].transit!=null){j+='<div class="hwan1">'+legs.steps[f].transit.departure_stop.name+"</div>";j+='<div class="hwan2">'+legs.steps[f].transit.arrival_stop.name+"</div>"}else{if(legs.steps[f]==legs.steps[legs.steps.length-1]){j+='<div class="end">'+legs.end_address+"</div>"}else{j+="<div>"+legs.steps[f].instructions+"</div>"}}}j+="</div>"}$(".rout-box").html(j);var k="";for(var f=0;f<legs.steps.length+1;f++){var a=al_info[f];var c=is_al[f];var l;if(c==1){l="text-danger"}else{l="text-muted"}k+='<div class="list-case">';k+="<div>";k+='<div class="panel-heading">';k+='<div class="panel-title">';k+="<div>";if(f==0){k+="<div>";if(is_al[0]==0){k+='<span id="alth_box"><span class="alarm-thumbnail text-muted"><i class="fa fa-circle-o"></i></span></span>'}else{k+='<span id="alth_box"><a id="althumb'+f+'" class="alarm-thumbnail text-danger" onclick="setAlthumb('+f+')"><i class="fa fa-clock-o"></i></a></span>'}k+='<span class="text-muted"> Step. '+(f+1)+"</span>";if(legs.steps[f].travel_mode==("WALKING")){k+='<img class="icon-pos" style="height: 20px; width: 20px" src="http://maps.gstatic.com/mapfiles/transit/iw/6/walk.png">'}else{k+='<img class="icon-pos" style="height: 20px; width: 20px" src="'+legs.steps[f].transit.line.vehicle.icon+'">'}k+="</div>";k+='<div class="loca-name">';if(legs.steps[f].travel_mode==("WALKING")){k+='<img class="icon-pos" style="height: 20px; width: 20px" src="http://maps.gstatic.com/mapfiles/transit/iw/6/walk.png">'}else{k+='<img class="icon-pos" style="height: 20px; width: 20px" src="'+legs.steps[f].transit.line.vehicle.icon+'">'}k+=legs.start_address+"에서 출발";k+="</div>";k+='<div class="sub_info">출발시간: <strong>'+legs.departure_time.text+"</strong></div>";if(is_al[0]==0){k+='<div id="alinfotxt" class="sub_info"><span>알람설정: <span class="text-warning">OFF</span></span></div>'}else{k+='<div id="alinfotxt" class="sub_info"><span>알람설정: 출발 <span id="altime'+f+'" class="text-danger"><strong>'+a+"분 전</strong></span></span></div>"}}else{k+="<div>";if(legs.steps[f-1].travel_mode!=("WALKING")){k+='<a id="althumb'+f+'" class="alarm-thumbnail '+l+'" onclick="setAlthumb('+f+')"><i class="fa fa-clock-o"></i></a>'}else{k+='<span class="alarm-thumbnail text-muted"><i class="fa fa-circle-o"></i></span>'}k+='<span class="text-muted"> Step. '+(f+1)+" </span>";if(legs.steps[f-1].travel_mode==("WALKING")){k+='<img class="icon-pos" style="height: 20px; width: 20px" src="http://maps.gstatic.com/mapfiles/transit/iw/6/walk.png">'}else{k+='<img class="icon-pos" style="height: 20px; width: 20px" src="'+legs.steps[f-1].transit.line.vehicle.icon+'">'}k+='<span class="text-danger"><strong>'+legs.steps[f-1].duration.text+"</strong></span>";k+="</div>";if(legs.steps[f-1].travel_mode!=("WALKING")){k+='<div class="loca-name">';k+='<img class="icon-pos" style="height: 20px; width: 20px" src="'+legs.steps[f-1].transit.line.vehicle.icon+'">';k+='<span class="icon-pos2" style="background-color:'+legs.steps[f-1].transit.line.color+'; padding:1px 4px 0px 4px; color: #ffffff">';k+="<strong>"+legs.steps[f-1].transit.line.short_name+"</strong>";k+="</span>";k+=legs.steps[f-1].transit.departure_stop.name+' <i class="fa fa-caret-right"></i> ';k+='<img class="icon-pos" style="height: 20px; width: 20px" src="'+legs.steps[f-1].transit.line.vehicle.icon+'">';k+=legs.steps[f-1].transit.arrival_stop.name;k+="</div>";k+='<div class="sub_info">출발시간: <strong>'+legs.steps[f-1].transit.departure_time.text+"</strong></div>";if(is_al[f]==0){k+='<div class="sub_info"><span>알람설정: <span id="altime'+f+'" class="text-warning">OFF</span></span></div>'}else{k+='<div class="sub_info"><span>알람설정: <img class="icon-pos1" style="height: 12px; width: 12px" src="'+legs.steps[f-1].transit.line.vehicle.icon+'">'+legs.steps[f-1].transit.arrival_stop.name+' 도착 <span id="altime'+f+'" class="text-danger"><strong>'+a+"m 전</strong></span></span></div>"}}else{if(f==1){k+='<div class="loca-name">';k+='<img class="icon-pos" style="height: 20px; width: 20px" src="http://maps.gstatic.com/mapfiles/transit/iw/6/walk.png">';k+=legs.start_address+' <i class="fa fa-caret-right"></i> ';k+='<img class="icon-pos" style="height: 20px; width: 20px" src="'+legs.steps[f].transit.line.vehicle.icon+'">';k+=legs.steps[f-1].instructions;k+="</div>";k+='<div class="sub_info">출발시간: <strong>'+legs.departure_time.text+"</strong></div>";k+='<div class="sub_info"><span>알람설정: <span id="altime'+f+'" class="text-warning">OFF</span></span></div>'}else{k+='<div class="loca-name">';k+='<img class="icon-pos" style="height: 20px; width: 20px" src="'+legs.steps[f-2].transit.line.vehicle.icon+'">';k+=legs.steps[f-2].transit.arrival_stop.name+' <i class="fa fa-caret-right"></i> ';if(f+1<legs.steps.length+1){k+='<img class="icon-pos" style="height: 20px; width: 20px" src="'+legs.steps[f].transit.line.vehicle.icon+'">';k+=legs.steps[f-1].instructions}else{k+=legs.end_address}k+="</div>";k+='<div class="sub_info">출발시간: <strong>'+legs.steps[f-2].transit.arrival_time.text+"</strong></div>";k+='<div class="sub_info"><span>알람설정: <span id="altime'+f+'" class="text-warning">OFF</span></span></div>'}}}k+="</div>";k+="</div>";k+="</div>";k+="</div>";k+="</div>"}$(".list-box").html(k);var h="";h+='<div class="text-center sub-header-box">';h+='<span>출발시간 <strong id="dep-time">'+legs.departure_time.text+"</strong> 도착시간 <strong";h+=' id="arr-time">'+legs.arrival_time.text+"</strong>";h+="</span>";h+="</div>";$(".clock").html(h);set_alarm()}function set_alarm(){if(step==0){if(is_al[step]==1){time_al=setInterval(time_alarm,60000)}else{if(is_al[step]==0){step++}}}}function time_alarm(){var b=new Date();var a=parseInt(legs.departure_time.value.substring(11,13))+9;var c=parseInt(legs.departure_time.value.substring(14,16));if(a>24){a-=24}c=c-parseInt(al_info[0]);if(c<0){a-=1;c+=60}if(b.getHours()==a){if(b.getMinutes()>=c){alert("time");playBeep();vibrate();clearInterval(time_al);step++}}};</script>
</body>
</html>